<?php
/**
 * Created by PhpStorm.
 * User: aako
 * Date: 15-12-10
 * Time: 下午3:05
 */

namespace App\Http\Requests\Admin\brand;

use App\Http\Requests\Request;

class StoreRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * 验证规则
     *
     * @return array
     */
    public function rules()
    {
        $rules =  [
            'brand_name' => 'required|unique:brand|max:16',
            'cat_id' => 'exists:category,cat_id',
        ];
        return $rules;

    }

    /**
     * 验证信息
     * @return array
     */

    public function messages()
    {
        return [
            'brand_name.required'  => '请填写品牌名称',
            'brand_name.unique'  => '品牌已存在',
            'brand_name.max'=>'品牌名称超过15个字',
            'cat_id.exists' => '所选商品分类不存在',
        ];
    }
}